package com.xyz.mqtt;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

/**
 * 启动服务的时候开启监听客户端
 */
@Configuration
public class MqttInit {

    @Autowired
    private MqttSendClient mqttSendClient;

    /**
     * 订阅mqtt
     */
    @Conditional(MqttCondition.class)
    @Bean
    public MqttSendClient getMqttPushClient() {
        mqttSendClient.connect();
        return mqttSendClient;
    }
}
